package service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import dao.SaleDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pojo.Sale;
import service.SaleService;
import util.CommonResult;
import util.Page;

import java.util.List;

@Service
public class SaleServiceImpl implements SaleService {
    @Autowired
    private SaleDao saleDao;

    @Override
    public CommonResult addSale(Sale sale) {
        int result = saleDao.addSale(sale);
        if (result == 1) {
            return new CommonResult(result);
        }
        return new CommonResult("添加失败");
    }

    @Override
    public CommonResult getSaleInfo(Integer currentNo, Integer typeSort) {
        Page page = new Page();
        page.setTotalCount(saleDao.getSaleInfoCount());
        page.setPageSize(3);
        page.setCurrentPageNo(currentNo);
        page.setDateTypeSort(typeSort);
        page.setSaleList(saleDao);
        return new CommonResult(page);
    }
}
